Git is a distributed version control system that helps developers track changes, collaborate efficiently, and manage code versions.
Git is a version control system, while GitHub is a hosting service that provides cloud-based repositories and collaboration tools.
You can use:
git reset --hard <commit-hash>
(Dangerous: overwrites history)git revert <commit-hash>
(Safer: creates a new commit that undoes changes)Use:
git status
to identify conflictsgit add <file>
and git commit
to save the resolved mergegit reset --soft HEAD~1
(Keep changes in staging)git reset --mixed HEAD~1
(Keep changes in working directory)git reset --hard HEAD~1
(Discard changes completely)Run git log
or git log --oneline --graph --all
for a structured view.
Use:
git branch feature-branch
(Create a new branch)git checkout feature-branch
or git switch feature-branch
(Switch to it)git stash
temporarily saves uncommitted changes without committing them, so you can switch branches safely.
Run:
git pull
and git fetch
?git fetch
downloads changes from the remote repository without applying them.git pull
downloads and merges the changes automatically.Answer:
git merge
and git rebase
?Answer:
git merge
creates a new merge commit and preserves history.git rebase
reapplies commits on top of another branch, making the history cleaner.Answer:
HEAD is a pointer that represents the current commit in a branch.
git pull
and git fetch
?Answer:
git fetch
downloads changes without merging.git pull
fetches and merges in one step.Answer:
git status
to check conflicts.git add <file>
.git commit -m "Resolved merge conflict"
.Answer:
git reset --soft HEAD~1
(Undo commit, keep changes staged)git reset --hard HEAD~1
(Undo commit and remove changes)git revert <commit-hash>
(Create a new commit that undoes changes)Answer:git stash
temporarily saves uncommitted changes. Use:
Answer:
git branch -d <branch-name>
git push origin --delete <branch-name>
Answer:
Use: git branch -r
git bisect
, and how does it help debug issues?Answer:git bisect
helps find a faulty commit using binary search:
We are Recommending you:
Step Out of Your Comfort Zone: 10 Powerful...
Is Mobile Reels Harming Our Children? Here's...
Simple body language tricks1. Stand with...
Best Free Websites to Learn CodingIf you...
Best Free Websites to Learn CodingIf you...
1. Tell Me About Yourself ?This is often the...
To place INR currency symbol in pdf while...
Is Mobile Reels Harming Our Children? Here's...
A class is an Object. We also name objects...